<?php
/**
 * Created by PhpStorm.
 * User: reshared
 * Date: 2017/10/2
 * Time: 上午11:17
 */

namespace Index\Model;


class AdModel extends BaseModel
{
//    ad_id 主键
//    key   标识
//    url   链接
//    text  标题
//    description  描述
//    img   图片链接
//    sort  排序 越大越靠后
    protected $tableName = 'ads';

    protected $pk = 'ad_id';

    public function getByKey($key)
    {
        return $this->where(array('key'=>$key))->order('sort')->find();
    }

    public function getByKeys($keys = array(), $limit = 1)
    {
        $key = implode(',', $keys);
        return $this->where("key in '{$key}'")->order('sort')->limit($limit)->select();
    }
}